home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / AppleTalk Wide Area / XTI Shell Sample Code / XTI includes / XTI.h < prev   
Encoding:
C/C++ Source or Header  |  1993-02-09  |  12.8 KB  |  498 lines  |  [TEXT/MPS ]

  1. #ifndef __XTI__
  2. #define __XTI__
  3. /*
  4.  *        XTI.h - Header file for XTI.
  5.  *
  6.  */
  7.  
  8. /* 
  9.  *        The following are the error codes needed by both the user level 
  10.  *        library and the XTI server.
  11.  */
  12.  
  13. #define TBADADDR        1    /* incorrect address format */
  14. #define TBADOPT            2    /* incorrect option format */
  15. #define TACCES            3    /* incorrect permissions */
  16. #define TBADF            4    /* illegal transport fd */
  17. #define TNOADDR            5    /* couldn't allocate addr */
  18. #define TOUTSTATE        6    /* out of state */
  19. #define TBADSEQ            7    /* bad call sequence number */
  20. #define TSYSERR            8    /* system error */
  21. #define TLOOK            9    /* event requires attention */
  22. #define TBADDATA        10    /* illegal amount of data */
  23. #define TBUFOVFLW        11    /* buffer not large enough */
  24. #define TFLOW            12    /* flow control */
  25. #define TNODATA            13    /* no data */
  26. #define TNODIS            14    /* discon_ind not found on queue */
  27. #define TNOUDERR        15    /* unitdata error not found */
  28. #define TBADFLAG        16    /* bad flags */
  29. #define TNOREL            17    /* no ord rel found on queue */
  30. #define TNOTSUPPORT        18    /* primitive/action not supported */
  31. #define TSTATECHNG        19    /* state is in process of changing */
  32. #define TNOSTRUCTYPE    20    /* unsupported struct-type requested */
  33. #define TBADNAME        21    /* invalid transport provider name */
  34. #define TBADQLEN        22    /* qlen is zero */
  35. #define TADDRBUSY        23    /* address in use */
  36. #define TINDOUT            24    /* outstanding connection indications */
  37. #define TPROVMISMATCH    25    /* transport provider mismatch */
  38. #define TRESQLEN        26    /* resfd specified to accept w/qlen > 0 */
  39. #define TRESADDR        27     /* resfd not bound to same addr as fd */
  40. #define TQFULL            28    /* incoming connection queue full */
  41. #define TPROTO            29    /* XTI protocol error */
  42.  
  43. /*
  44.  *        The following are the events returned.
  45.  */
  46.  
  47. #define T_LISTEN        0x0001    /* connection indication received */
  48. #define T_CONNECT        0x0002    /* connect confirmation received */
  49. #define T_DATA            0x0004    /* normal data received */
  50. #define T_EXDATA        0x0008    /* expedited data received */
  51. #define T_DISCONNECT    0x0010    /* disconnect received */
  52. #define T_UDERR            0x0040    /* datagram error indication */
  53. #define T_ORDREL        0x0080    /* orderly release indication */
  54. #define T_GODATA        0x0100    /* sending normal data is again possible */
  55. #define T_GOEXDATA        0x0200    /* sending expedited data is again possible */
  56.  
  57. /* macintosh extension for async notification of event    */
  58.  
  59. #define T_BINDCOMPLETE            0x00001000    /* async bind response received            */
  60. #define T_UNBINDCOMPLETE        0x00002000    /* async unbind response received         */
  61. #define T_ACCEPTCOMPLETE        0x00004000    /* async accept response received        */
  62. #define T_SENDCOMPLETE            0x00008000    /* async snd response received            */
  63. #define T_DISCONNECTCOMPLETE    0x00040000    /* async disconnect response received    */
  64. #define T_OPTMGMTCOMPLETE        0x00080000    /* async option mgmt response received    */
  65. #define T_PASSCON                0x00800000    /* async conn. accepted event             */
  66.  
  67. /*
  68.  *        The following are the flag definitions needed by the user level
  69.  *        library routines.
  70.  */
  71.  
  72. #define T_MORE            0x001    /* more data */
  73. #define T_EXPEDITED        0x002    /* expedited data */
  74. #define T_NEGOTIATE        0x004    /* set opts */
  75. #define T_CHECK            0x008    /* check opts */
  76. #define T_DEFAULT        0x010    /* get default opts */
  77. #define T_SUCCESS        0x020    /* successful */
  78. #define T_FAILURE        0x040    /* failure */
  79. #define T_CURRENT        0x080    /* get current options */
  80.  
  81. /*
  82.  *    O_NONBLOCK is included here as it normally is in <fcntl.h> but not for
  83.  *        the MPW Interfaces.
  84.  */
  85. #ifndef O_NONBLOCK
  86. #define O_NONBLOCK        0x00004000
  87. #endif
  88.  
  89. /*
  90.  *    XTI error return.
  91.  */
  92.  
  93. #define t_errno t_ERRNO (-1)                /* -1 must not be a valid file descriptor         */
  94.  
  95. #ifdef __cplusplus
  96. extern "C" {
  97. #endif
  98.  
  99. extern int t_ERRNO (int fd);                /* returns the errno associated with the fd     */
  100.  
  101. /* XTI Library functions */
  102. extern int t_accept(int fd,int resfd,struct t_call *call);
  103. extern char *t_alloc( int fd, int struct_type, int fields );
  104. extern int t_bind(int fd,struct t_bind *req,struct t_bind *ret);
  105. extern int t_close(int fd);
  106. extern int t_connect(int fd,struct t_call *sndcall,struct t_call *rcvcall);
  107. extern int t_error( char * errmsg ); 
  108. extern int t_free( char *ptr, int struct_type );  
  109. extern int t_getinfo( int fd,struct t_info *info );
  110. extern int t_getprotaddr( int fd, struct t_bind *boundaddr, struct t_bind *peeraddr );
  111. extern int t_getstate( int fd );
  112. extern int t_listen(int fd,struct t_call *call);
  113. extern int t_look( int fd );
  114. extern int t_open(char * name,int oflag,struct t_info *info);
  115. extern int t_optmgmt( int fd, struct t_optmgmt *req, struct t_optmgmt *ret );
  116. extern int t_rcv(int fd,char *buf,unsigned int nbytes,int *flags);
  117. extern int t_rcvconnect( int fd, struct t_call *call );
  118. extern int t_rcvdis( int fd, struct t_discon *discon );
  119. extern int t_rcvrel( int fd ); 
  120. extern int t_rcvudata( int fd, struct t_unitdata *unitdata, int * flags ); 
  121. extern int t_rcvuderr( int fd, struct t_uderr *uderr ); 
  122. extern int t_snd(int fd,char *buf,unsigned int nbytes,int flags);
  123. extern int t_snddis(int fd,struct t_call *call);
  124. extern int t_sndrel( int fd );
  125. extern int t_sndudata( int fd, struct t_unitdata *unitdata );
  126. extern char *t_strerror( int errnum );
  127. extern int t_sync( int fd );
  128. extern int t_unbind(int fd);
  129.  
  130. #ifdef __cplusplus
  131. }
  132. #endif
  133.  
  134.  
  135. /*
  136.  *        Protocol specific service limits.
  137.  */
  138.  
  139. struct t_info{
  140.     long            addr;        /* size of protocol address */
  141.     long            options;    /* size of protocol options */
  142.     long            tsdu;        /* size of max transport service data unit */
  143.     long            etsdu;        /* size of max expedited tsdu */
  144.     long            connect;    /* max data for connect primitives */
  145.     long            discon;        /* max data for disconnect primitives */
  146.     long            servtype;    /* provider service type */
  147.     long            flags;        /* other info about the transport provider */
  148. };
  149.  
  150. /*
  151.  *        Service type defines. 
  152.  */
  153.  
  154. #define T_COTS            01        /* connection-oriented transport service */
  155. #define T_COTS_ORD        02        /* connection-oriented with orderly release */
  156. #define T_CLTS            03        /* connectionless transport service */
  157.  
  158. /* 
  159.  *    Flags defines (other info about the transport provider).
  160.  */
  161.  
  162. #define T_SENDZERO        0x001    /* supports 0-length TSDUs */
  163.  
  164. /*
  165.  *        netbuf structure
  166.  */
  167.  
  168. struct netbuf{
  169.     unsigned int    maxlen;
  170.     unsigned int    len;
  171.     char            *buf;
  172. };
  173.  
  174. /*
  175.  * t_opthdr structure
  176.  */
  177. struct t_opthdr {
  178.     unsigned long len;        /* total length of option;i.e
  179.                               sizeof(struct t_opthdr)+length of
  180.                               option value in bytes */
  181.     unsigned long level;    /* protocol affected */
  182.     unsigned long name;        /* option name */
  183.     unsigned long status;    /* status value */
  184. /* followed by option value */
  185. };
  186.  
  187. /*
  188.  *        t_bind - format of the address and options arguments of bind.
  189.  */
  190.  
  191. struct t_bind{
  192.     struct netbuf    addr;
  193.     unsigned int    qlen;
  194. };
  195.  
  196. /*
  197.  *    Options management structure.
  198.  */
  199.  
  200. struct t_optmgmt{
  201.     struct netbuf    opt;
  202.     long            flags;
  203. };
  204.  
  205. /*
  206.  *        Disconnect structure.
  207.  */
  208.  
  209. struct t_discon{
  210.     struct netbuf    udata;        /* user data */
  211.     int                reason;        /* reason code */
  212.     int                sequence;    /* sequence number */
  213. };
  214.  
  215. /*
  216.  *        Call structure.
  217.  */
  218.  
  219. struct t_call{
  220.     struct netbuf    addr;        /* address */
  221.     struct netbuf    opt;        /* options */
  222.     struct netbuf    udata;        /* user data */
  223.     int                sequence;    /* sequence number */
  224. };
  225.  
  226. /*
  227.  *        Datagram structure.
  228.  */
  229.  
  230. struct t_unitdata{
  231.     struct netbuf    addr;        /* address */
  232.     struct netbuf    opt;        /* options */
  233.     struct netbuf    udata;        /* user data */
  234. };
  235.  
  236. /*
  237.  *        Unitdata error structure.
  238.  */
  239. struct t_uderr{
  240.     struct netbuf    addr;        /* address */
  241.     struct netbuf    opt;        /* options */
  242.     long            error;        /* error code */
  243. };
  244.  
  245. /*
  246.  *        The following are structure types used when dynamically
  247.  *        allocating the above structures via t_alloc().
  248.  */
  249.  
  250. #define T_BIND            1        /* struct t_bind */
  251. #define T_OPTMGMT        2        /* struct t_optmgmt */
  252. #define T_CALL            3        /* struct t_call */
  253. #define T_DIS            4        /* struct t_discon */
  254. #define T_UNITDATA        5        /* struct t_unitdata */
  255. #define T_UDERROR        6        /* struct t_uderr */
  256. #define T_INFO            7        /* struct t_info */
  257.  
  258. /*
  259.  *        The following bits specify which fields of the above
  260.  *        structures should be allocated by t_alloc().
  261.  */
  262.  
  263. #define T_ADDR            0x01    /* address */
  264. #define T_OPT            0x02    /* options */
  265. #define T_UDATA            0x04    /* user data */
  266. #define T_ALL            0xffff    /* all of the above fields supported */
  267.  
  268. /*
  269.  *        The following are the states for the user.
  270.  */
  271.  
  272. #define T_UNBND            1        /* unbound */
  273. #define T_IDLE            2        /* idle */
  274. #define T_OUTCON        3        /* outgoing connection pending */
  275. #define T_INCON            4        /* incoming connection pending */
  276. #define T_DATAXFER        5        /* data transfer */
  277. #define T_OUTREL        6        /* outgoing release pending */
  278. #define T_INREL            7        /* incoming release pending */
  279.  
  280. /*
  281.  *        General purpose defines.
  282.  */
  283.  
  284. #define T_YES            1
  285. #define T_NO            0
  286. #define T_UNUSED        -1
  287. #define T_NULL            0
  288. #define T_ABSREQ        0x8000
  289. #define T_INFINITE        -1
  290. #define T_INVALID        -2
  291.  
  292. /* T_INFINITE and T_INVALID are valued of t_info */
  293.  
  294. /**********************************************************************
  295. * General definitions for option management
  296. ***********************************************************************/
  297.  
  298. #define T_UNSPEC    (~0 - 2)
  299. #define T_ALLOPT    0
  300. #define T_ALIGN(p)    (((unsigned long)(p)+(sizeof(long) - 1))    \
  301.                     & ~(sizeof(long) - 1))
  302.                     
  303. #define OPT_NEXTHDR(pbuf, buflen, popt)        \
  304.         (((char*)(popt)+T_ALIGN((popt)->len) < \
  305.         pbuf + buflen) ? \
  306.         (struct t_opthdr *) ((char*)(popt)+T_ALIGN((popt)->len)) : \
  307.         (struct t_opthdr *) NULL)
  308.  
  309.  
  310. /*    -------------------------------------------------------------------------
  311.     XTI_GENERIC Options
  312.     ------------------------------------------------------------------------- */
  313.  
  314. #define XTI_GENERIC    0xffff            /* XTI Level    */
  315.  
  316. #define XTI_DEBUG        0x0001    /* enable debugging                    */
  317. #define XTI_LINGER        0x0080    /* Linger on close if data present    */
  318. #define XTI_RCVBUF        0x1002    /* Receive buffer size                */
  319. #define XTI_RCVLOWAT    0x1004    /* Receive low-water mark            */
  320. #define XTI_SNDBUF        0x1001    /* Send buffer size                    */
  321. #define XTI_SNDLOWAT    0x1003    /* Send low-water mark                */
  322.  
  323. // Structure used with the XTI_LINGER Option
  324.  
  325. struct t_linger
  326. {
  327.     long    l_onoff;        /* option on/off    */
  328.     long    l_linger;        /* linger time        */
  329. };
  330.  
  331.  
  332.     /* SPECIFIC ISO OPTION AND MANAGEMENT PARAMETERS */
  333.     
  334. /*
  335.  *        Definition of the ISO transport classes.
  336.  */
  337.  
  338. #define T_CLASS0        0
  339. #define T_CLASS1        1
  340. #define T_CLASS2        2
  341. #define T_CLASS3        3
  342. #define T_CLASS4        4
  343.  
  344. /*
  345.  *        Definition of the priorities. 
  346.  */
  347.  
  348. #define T_PRITOP        0
  349. #define T_PRIHIGH        1
  350. #define T_PRIMID        2
  351. #define T_PRILOW        3
  352. #define T_PRIDFLT        4
  353.  
  354. /*
  355.  *        Definition of the protection levels.
  356.  */
  357.  
  358. #define T_NOPROTECT            1
  359. #define T_PASSIVEPROTECT    2
  360. #define T_ACTIVEPROTECT        4
  361.  
  362. /*
  363.  *        Default value for the length of TPDU's.
  364.  */
  365.  
  366. #define T_LTPDUDFLT        128
  367.  
  368. /*
  369.  *        rate structure
  370.  */
  371.  
  372. struct rate{
  373.     long            targetvalue;    /* target value */
  374.     long            minacceptvalue;    /* minimum acceptable value */
  375. };
  376.  
  377. /*
  378.  *        reqvalue structure
  379.  */
  380.  
  381. struct reqvalue{
  382.     struct rate        called;            /* called rate */
  383.     struct rate        calling;        /* calling rate */
  384. };
  385.  
  386. /*
  387.  *        thrpt structure
  388.  */
  389.  
  390. struct thrpt{
  391.     struct reqvalue    maxthrpt;        /* maximum throughput */
  392.     struct reqvalue avgthrpt;        /* average throughput */
  393. };
  394.  
  395. struct transdel{
  396.     struct reqvalue    maxdel;            /* maximum transit delay */
  397.     struct reqvalue    avgdel;            /* average transit delay */
  398. };
  399.  
  400.  
  401. /*    -------------------------------------------------------------------------
  402.     Protocol Levels
  403.     ------------------------------------------------------------------------- */
  404.  
  405. #define ISO_TP        0x0100
  406.  
  407. /*
  408. * Options for Quality of Service and Expedited Data (ISO 8072:1986)
  409. */
  410.  
  411. #define TCO_THROUGHPUT        0x0001
  412. #define TCO_TRANSDEL        0x0002
  413. #define TCO_RESERRORRATE    0x0003
  414. #define TCO_TRANSFFAILPROB    0x0004
  415. #define TCO_ESTFAILPROB        0x0005
  416. #define TCO_RELFAILPROB        0x0006
  417. #define TCO_ESTDELAY        0x0007
  418. #define TCO_RELDELAY        0x0008
  419. #define TCO_CONNRESIL        0x0009
  420. #define TCO_PROTECTION        0x000a
  421. #define TCO_PRIORITY        0x000b
  422. #define TCO_EXPD            0x000c
  423.  
  424. #define TCL_TRANSDEL        0x000d
  425. #define TCL_RESERRORRATE    TCO_RESERRORRATE
  426. #define TCL_PROTECTION        TCO_PROTECTION
  427. #define TCL_PRIORITY        TCO_PRIORITY
  428.  
  429. /*
  430. * Management Options
  431. */
  432.  
  433. #define TCO_LTPDU            0x0100
  434. #define TCO_ACKTIME            0x0200
  435. #define TCO_REASTIME        0x0300
  436. #define TCO_EXTFORM            0x0400
  437. #define TCO_FLOWCTRL        0x0500
  438. #define TCO_CHECKSUM        0x0600
  439. #define TCO_NETEXP            0x0700
  440. #define TCO_NETRECPTCF        0x0800
  441. #define TCO_PREFCLASS        0x0900
  442. #define TCO_ALTCLASS1        0x0a00
  443. #define TCO_ALTCLASS2        0x0b00
  444. #define TCO_ALTCLASS3        0x0c00
  445. #define TCO_ALTCLASS4        0x0d00
  446.  
  447. #define TCL_CHECKSUM        TCO_CHECKSUM
  448.  
  449.  
  450.     /* INTERNET SPECIFIC ENVIRONMENT */
  451.  
  452.  
  453. /*
  454. * TCP level
  455. */
  456. #define INET_TCP    0x0006
  457. #define INET_UDP    0x0011
  458. #define INET_IP        0x0000
  459.  
  460.  
  461.  
  462. /* 
  463.  *    TCP precedence levels.
  464.  */
  465. #define T_ROUTINE        0
  466. #define T_PRIORITY        1
  467. #define T_IMMEDIATE        2
  468. #define T_FLASH            3
  469. #define T_OVERRIDEFLASH    4
  470. #define T_CRITIC_ECP    5
  471. #define T_INETCONTROL    6
  472. #define T_NETCONTROL    7
  473.  
  474. /*
  475.  *    TCP security options structure. 
  476.  */
  477. struct secoptions{
  478.     short    security;        /* security field */
  479.     short    compartment;    /* compartment */
  480.     short    handling;        /* handling restrictions */
  481.     long    tcc;            /* transmission control code */
  482. };
  483.  
  484. /* 
  485.  *    TCP options.
  486.  */
  487. struct tcp_options{
  488.     short                precedence;        /* precedence */
  489.     long                timeout;        /* abort timeout */
  490.     long                max_seg_size;    /* maximum security size */
  491.     struct secoptions    secopt;            /* TCP security options */
  492. };
  493.  
  494. #endif /* __XTI__ */
  495.  
  496.  
  497.  
  498.